from urllib.parse import urljoin,urlencode,parse_qs,parse_qsl,quote,unquote

print(urljoin('http://www.baidu.com', "FAQ.html"))
print(urljoin('http://www.baidu.com', "https://cuiqingcai.com/FAQ.html"))
print(urljoin('http://www.baidu.com/about.html', "https://cuiqingcai.com/FAQ.html?question=2"))
print(urljoin('http://www.baidu.com?wd=abc', "https://cuiqingcai.com/index.php"))
print(urljoin('www.baidu.com', "?category=2#comment1"))
print(urljoin('www.baidu.com#comment2', "?category=2"))

params = {
    'name': 'germey',
    'age': 22
}
base_url = "http://www.baidu.com"
encodeParam = urlencode(params)
url=base_url + encodeParam
print(url)
dictParam = parse_qs(encodeParam)
print(dictParam)
param = parse_qsl(encodeParam)
print(param)
keyword = '中文壁纸'
quoteKey=quote(keyword)
url=base_url+"?wd="+quoteKey
print(url)
unQuoteKey=unquote(quoteKey)
print(unQuoteKey)